<?php
/**
 * @version $Id: logfiles.php 1144 2010-03-29 13:38:58Z elkuku $
 * @package    EasyCreator
 * @subpackage Controllers
 * @author     EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org}
 * @author     Nikolai Plath {@link http://www.nik-it.de}
 * @author     Created on 23-Sep-2008
 * @license    GNU/GPL, see JROOT/LICENSE.php
 */

//-- No direct access
defined('_JEXEC') or die('=;)');

jimport('joomla.application.component.controller');

/**
 * EasyCreator Controller
 *
 * @package    EasyCreator
 * @subpackage Controllers
 */
class EasyCreatorControllerLogfiles extends JController
{
    /**
     * Constructor.
     *
     * @param array $config Configuration.
     */
    function __construct($config = array())
    {
        parent::__construct($config);
    }// function

    /**
     * Standard display method.
     */
    function display()
    {
        JRequest::setVar('view', 'logfiles');
        parent::display();
    }// function

    /**
     * deletes ALL log files (no warning..)
     *
     */
    function clear_log()
    {
        $logfiles = JFolder::files(ECRPATH_LOGS, 'log', false, true);

        if(count($logfiles))
        {
            if(JFile::delete($logfiles))
            {
                JFactory::getApplication()->enqueueMessage(JText::_('The logfiles have been deleted'));
                JRequest::setVar('view', 'easycreator');
            }
            else
            {
                JError::raiseWarning(100, JText::_('The logfiles could not be deleted'));
                JRequest::setVar('view', 'logfiles');
            }
        }

        parent::display();
    }//function

}//class
